package cn.com.nthotline.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import cn.com.nthotline.R;

public class LoadingLayout extends LinearLayout {
	private Context context;
	private ProgressBar bar;
	private TextView text;

	public LoadingLayout(Context context, AttributeSet attrs) {
		super(context, attrs);
		this.context = context;
		init();
	}

	public LoadingLayout(Context context) {
		super(context);
		this.context = context;
		init();
	}

	private void init() {
		View view = LayoutInflater.from(context).inflate(R.layout.loaddata,
				null);
		bar = (ProgressBar) view.findViewById(R.id.loaddata_pro_loaddata);
		text = (TextView) view.findViewById(R.id.tvMsg);
		addView(view);
	}

	public TextView getText() {
		return text;
	}

	public void setMsg(String msg) {
		text.setText(msg);
	}

	public void show() {
		this.setVisibility(View.VISIBLE);
	}

	public void hide() {
		this.setVisibility(View.GONE);
	}

	@Override
	public void onWindowFocusChanged(boolean hasFocus) {
		super.onWindowFocusChanged(hasFocus);
	}
}
